package 集合;

import java.util.LinkedList;
import java.util.Queue;

public class test {
    public static void main(String[] args) {
        test test = new test();
        test.maximumPrimeDifference(new int[]{3,17});
    }

    public int maximumPrimeDifference(int[] nums) {
        int i=0;
        int j=nums.length-1;
        int f1=-1,f2=-1;
        while(i<=j){
            if(f1 == -1){
                if(isZX(nums[i])){
                    f1 = i;
                }
                i++;
            }
            if(f2 == -1){
                if(isZX(nums[j])){
                    f2 = j;
                }
                j--;
            }
            if(f1 != -1 && f2!= -1){
                return f2-f1;
            }
        }
        if(f1 == -1 || f2 == -1){
            return 0;
        }else{
            return f2-f1;
        }
    }

    public boolean isZX(int target){
        for(int i=2;i< target;i++){
            if(target%i == 0){
                return false;
            }
        }
        return true;
    }
}


